package com.iflytek.bestsellers;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class BestSumMapper extends Mapper<LongWritable, Text, Text, BestCountBean> {

    Text outKey = new Text();
    BestCountBean outValue = new BestCountBean();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String[] fields = value.toString().split(",");
        //类型
        outKey.set(fields[2]);
        //Best数据 评论数 定价
        outValue.set(Long.parseLong(fields[fields.length-2]),Long.parseLong(fields[fields.length-1]));
        //map输出结果
        context.write(outKey,outValue);
    }
}